$width or $height_orig > $height) { if(is_file("$cache/$width/$height/{$_GET['file']}") and $cacheAttiva) { $imageDest = $imagecreate("$cache/$width/$height/{$_GET['file']}"); } else { if(isset($_GET['crop'])) { $rapp_larg = $width_orig / $width; $rapp_alt = $height_orig / $height; if($rapp_larg > $rapp_alt) { $src_x = ($width_orig - ($width * $rapp_alt)) / 2; $width_orig -= $src_x * 2; } else if ($rapp_larg < $rapp_alt) { $src_y = ($height_orig - ($height * $rapp_larg)) / 2; $height_orig -= $src_y * 2; } } else { if ($width && ($width_orig < $height_orig)) { $width = round(($height / $height_orig) * $width_orig); } else { $height = round(($width / $width_orig) * $height_orig); } } $imageSrc = $imagecreate($_GET['file']); // The recommended approach is the usage of the GD2.x functions. // Create an empty thumbnail image. $imageDest = imagecreatetruecolor($width, $height); // Try to create the thumbnail from the source image. imagecopyresampled($imageDest, $imageSrc, 0, 0, $src_x, $src_y, $width, $height, $width_orig, $height_orig); // save the thumbnail image into a file. /* rounded corners */ if($_GET['corners']) { $radius = $_GET['corners']; $diametro = $radius * 2; $roundedcorners = imagecreatetruecolor($diametro, $diametro); imagealphablending($roundedcorners, false); imagealphablending($imageDest, false); $sfondo = imagecolorallocate($roundedcorners, 255, 255, 255); $cerchio = imagecolorallocatealpha($roundedcorners, 0, 0, 0, 0); imagecolortransparent($roundedcorners, $cerchio); imagefilledrectangle($roundedcorners, 0, 0, $diametro, $diametro, $sfondo); imagefilledellipse($roundedcorners, $radius, $radius, $diametro, $diametro, $cerchio); imagesavealpha($roundedcorners, true); //imagepng($roundedcorners); imagecopymerge($imageDest, $roundedcorners, 0, 0, 0, 0, $radius, $radius, 100); imagecopymerge($imageDest, $roundedcorners, $width - $radius, 0, $radius, 0, $radius, $radius, 100); imagecopymerge($imageDest, $roundedcorners, $width - $radius, $height - $radius, $radius, $radius, $radius, $radius, 100); imagecopymerge($imageDest, $roundedcorners, 0, $height - $radius, 0, $radius, $radius, $radius, 100); imagedestroy($roundedcorners); } /* REFLECTION! */ if($_GET['reflection']) { $imgImport = $imageDest; $gradientHeight = $_GET['reflection']; $transparency = 40; //from 0 - 100 $imgName_w = $width; $imgName_h = $height; // Create new blank image with sizes. $background = imagecreatetruecolor($imgName_w, $gradientHeight); $gradientColor = "255 255 255"; //White $gradparts = explode(" ",$gradientColor); // get the parts of the colour (RRR,GGG,BBB) $dividerHeight = 1; $gradient_y_startpoint = $dividerHeight; $gdGradientColor=ImageColorAllocate($background,$gradparts[0],$gradparts[1],$gradparts[2]); $newImage = imagecreatetruecolor($imgName_w, $imgName_h); for ($x = 0; $x < $imgName_w; $x++) { for ($y = 0; $y < $imgName_h; $y++) { imagecopy($newImage, $imgImport, $x, $imgName_h - $y - 1, $x, $y, 1, 1); } } // Add it to the blank background image imagecopymerge ($background, $newImage, 0, 0, 0, 0, $imgName_w, $imgName_h, 100); //create from a the image so we can use fade out. $gradient_line = imagecreatetruecolor($imgName_w, 1); // Next we draw a GD line into our gradient_line imageline ($gradient_line, 0, 0, $imgName_w, 0, $gdGradientColor); $i = 0; while ($i < $gradientHeight) //create line by line changing as we go { imagecopymerge ($background, $gradient_line, 0,$gradient_y_startpoint, 0, 0, $imgName_w, 1, $transparency); ++$i; ++$gradient_y_startpoint; if ($transparency == 100) { $transparency = 100; } else { // this will determing the height of the //reflection. The higher the number, the smaller the reflection. //1 being the lowest(highest reflection) $transparency = $transparency + 1; } } // Set the thickness of the line we're about to draw imagesetthickness ($background, $dividerHeight); // Draw the line imageline ($background, 0, 0, $imgName_w, 0, $gdGradientColor); $finalImage = imagecreatetruecolor($imgName_w, $imgName_h + $gradientHeight); imagecopy($finalImage, $imageDest, 0, 0, 0, 0, $imgName_w, $imgName_h); imagecopy($finalImage, $background, 0, $imgName_h, 0, 0, $imgName_w, $imgName_h); $imageDest = $finalImage; } $partial_path = explode("/", $_GET['file']); array_pop($partial_path); $partial_path = implode("/", $partial_path); mkdir_r("$cache/$req_width/$req_height/$partial_path"); chmod("$cache/$req_width/$req_height/$partial_path", 0777); if($req_width + $req_height > 500) imagejpeg($imageDest, "$cache/$req_width/$req_height/".str_replace('.png', '.jpg', $_GET['file'])); else imagepng($imageDest, "$cache/$req_width/$req_height/".str_replace(array('.jpg', '.JPG', '.jpeg'), '.png', $_GET['file'])); } } else { $imageDest = $imagecreate($_GET['file']); } imagejpeg($imageDest); if($imageSrc) imagedestroy($imageSrc); imagedestroy($imageDest); if($_GET['reflection']) { imagedestroy($background); imagedestroy($gradient_line); imagedestroy($newImage); } ?>